<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<%@page import="com.liferay.portal.theme.ThemeDisplay"%>
<%@page import="com.liferay.counter.service.CounterLocalServiceUtil"%>
<%@page import="it.apuliait.service.RiceventeLocalServiceUtil"%>
<%@page import="it.apuliait.model.Ricevente"%>
<%@page import="it.apuliait.model.DocumentoXml"%>
<%@page import="it.apuliait.service.DocumentoXmlLocalServiceUtil"%>
<%@page import="it.apuliait.model.Documento"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="javax.portlet.PortletURL"%>
<%@page import="javax.portlet.ActionRequest"%>
<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>

<script src="http://cdn.alloyui.com/3.0.0/aui/aui-min.js"></script>
<link href="http://cdn.alloyui.com/3.0.0/aui-css/css/bootstrap.min.css" rel="stylesheet"></link>

<portlet:defineObjects />

<div style="display: inline-flex;">
	
	<form method="post" action="<portlet:renderURL><portlet:param name="nuovoRicevente" value="nuovoRicevente" /><portlet:param name="scelta" value="AGGIUNGI_COMMITTENTE" /></portlet:renderURL>">
		<input type="submit" value="Nuovo Ricevente"/>
	</form>
			
</div>

<p><b>ELENCO RICEVENTI</b></p>

<% 
ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
List<Ricevente> list_ricevente = RiceventeLocalServiceUtil.getRiceventiByUserId(themeDisplay.getUserId());

PortletURL iteratorURL = renderResponse.createRenderURL();
List<Ricevente> displayList = new ArrayList<Ricevente>();
pageContext.setAttribute("list_ricevente", list_ricevente);

%>


<form name="modulo">
	<liferay-ui:search-container delta="10" emptyResultsMessage="Nessun Ricevente Registrato" iteratorURL="<%= iteratorURL %>" >
	<%
	
	if(list_ricevente!=null && list_ricevente.size()>0 ){	  
		displayList = list_ricevente.subList(searchContainer.getStart(), list_ricevente.size());
	}
	if( searchContainer.getEnd() < list_ricevente.size()){
		displayList=list_ricevente.subList(searchContainer.getStart(), searchContainer.getEnd());
	}
	
	pageContext.setAttribute("displayList", displayList);
	
	%>
	<liferay-ui:search-container-results results="<%= displayList %>" total="<%= list_ricevente.size() %>" />
	     <liferay-ui:search-container-row className="it.apuliait.model.Ricevente" keyProperty="riceventeId" modelVar="ricevente" >
	       	<liferay-ui:search-container-column-text name="Ricevente" >
	       		 <a href="<portlet:renderURL>
	       		 				<portlet:param name="riceventeId" value="<%= String.valueOf(ricevente.getRiceventeId()) %>" />
	       		 				<portlet:param name="scelta" value="MODIFICA_RICEVENTE" />
	       		 		</portlet:renderURL>"><%= ricevente.getRagioneSocialeRic() %></a>
	       	</liferay-ui:search-container-column-text>
	    	
	    </liferay-ui:search-container-row>
	    <liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
	</liferay-ui:search-container>
</form>